#!/bin/bash

#设置全局email
#git config --global user.email "huajie.bao@transsnet.com@transsnet.com"
#设置全局name
#git config --global user.name "baohuajie"
#需要更新的分支
echo "请输入工程目录:"
read project_path;
cd $project_path;
str="pc"
#查看当前目录
pwd_paths=`find ./ -maxdepth 1 -type d | grep "${str}"`;
echo "当前目录下的工程如下:"
for dir in $pwd_paths 
do 
	echo $dir;
done


## 开始编译yan
echo "============================================================开始编译yan============================================================"
cd "$project_path/$str-yan"
echo "当前目录$(pwd)" 
mvn clean 
mvn install -Dmaven.test.skip=true
echo "============================================================结束编译yan============================================================"
# 开编译repos


## 开始编译idg
echo "============================================================开始编译idg============================================================"
cd "$project_path/$str-idg"
echo "当前目录$(pwd)" 
mvn clean 
mvn install -Dmaven.test.skip=true
echo "============================================================结束编译idg============================================================"

## 开始编译tms
echo "============================================================开始编译tms============================================================"
cd "$project_path/$str-tms"
echo "当前目录$(pwd)" 
mvn clean 
mvn install -Dmaven.test.skip=true
echo "============================================================结束编译tms============================================================"

## 开始编译ppy
echo "============================================================开始编译ppy============================================================"
cd "$project_path/$str-ppy"
echo "当前目录$(pwd)" 
mvn clean 
mvn install -Dmaven.test.skip=true
echo "============================================================结束编译ppy============================================================"

## 开始编译infr
echo "============================================================开始编译infr============================================================"
cd "$project_path/$str-infr"
echo "当前目录$(pwd)" 
mvn clean 
mvn install -Dmaven.test.skip=true
echo "============================================================结束编译infr============================================================"


echo "============================================================开始编译repos============================================================"
for dir in $pwd_paths 
do 
	cd $dir
	var1=`echo $dir|awk -F '-' '{print $2}'`
	if [[ "$var1" == "yan" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "ppy" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "idg" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "infr" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "tms" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	else
		echo "进入目录$var1-repos"
		cd "$var1-repos"
		echo "当前目录$(pwd)" 
		mvn clean 
		mvn install -Dmaven.test.skip=true
		cd $project_path
	fi
	
	
done
echo "============================================================结束编译repos============================================================"


echo "============================================================开始编译pojo============================================================"
for dir in $pwd_paths 
do 
	cd $dir
	var1=`echo $dir|awk -F '-' '{print $2}'`
	if [[ "$var1" == "yan" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "ppy" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "idg" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "infr" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "tms" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	else
		echo "进入目录$var1-pojo"
		cd "$var1-pojo"
		echo "当前目录$(pwd)" 
		mvn clean 
		mvn install -Dmaven.test.skip=true
		cd $project_path
	fi
	
	
done
echo "============================================================结束编译pojo============================================================"


echo "============================================================开始编译service-api============================================================"
for dir in $pwd_paths 
do 
	cd $dir
	var1=`echo $dir|awk -F '-' '{print $2}'`
	if [[ "$var1" == "yan" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "ppy" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "idg" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "infr" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	elif [[ "$var1" == "tms" ]]; 
	then
		echo "============================================================跳过$var1============================================================"
	else
		echo "进入目录$var1-service-api"
		cd "$var1-service-api"
		echo "当前目录$(pwd)" 
		mvn clean 
		mvn install -Dmaven.test.skip=true
		cd $project_path
	fi
	
	
done
echo "============================================================结束编译service-api============================================================"